package com.zrentech.order.ui;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

import com.zrentech.order.R;
import com.zrentech.order.adapter.FoodAdapter;
import com.zrentech.order.adapter.FoodTypeAdapter;
import com.zrentech.order.data.busibean.FoodBean;
import com.zrentech.order.data.dbhelper.DatabaseImpl;

public class MenuActivity extends Activity {
	
	public static void launch(Context c){
		Intent intent = new Intent(c, MenuActivity.class);
		intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP );
		c.startActivity(intent);
	}
	
	private ListView mFoodCategoryListView;	
	private FoodTypeAdapter mFoodCategoryAdapter;
	private List<FoodBean> listFood;
	
	private ListView mFoodListView;
	private FoodAdapter mFoodAdapter;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.menu);
        
        /*mFoodCategoryListView = (ListView)findViewById(R.id.list_right_listview);
        mFoodCategoryAdapter = new FoodTypeAdapter(this);
        mFoodCategoryAdapter.setList(new DatabaseImpl(MenuActivity.this).getFoodCategoryList());
		mFoodCategoryListView.setAdapter(mFoodCategoryAdapter);
		mFoodCategoryListView.setOnItemClickListener(mFoodCategoryListListener);
		
		mFoodListView = (ListView)findViewById(R.id.list_right_listview);
        mFoodAdapter = new FoodAdapter(this);
        mFoodAdapter.setList(new DatabaseImpl(MenuActivity.this).getFoodList(null, 20));
		mFoodListView.setAdapter(mFoodAdapter);
		mFoodListView.setOnItemClickListener(mFoodCategoryListListener);*/
    }
    
	/**
	 * Launch food list
	 */
	private OnItemClickListener mFoodCategoryListListener = new OnItemClickListener(){

		@Override
		public void onItemClick(AdapterView<?> arg0, View arg1, int position,
				long arg3) {
			/*FoodCategory category = (FoodCategory)mFoodCategoryAdapter.getItem(position);
			//try {
				listFood = new ArrayList<Food>();
				listFood = new DatabaseImpl(MenuActivity.this).getFoodList(category, 20);
				*/
				// add to ListView
				
		    	/*Intent intentFoodDetail = new Intent(IndexActivity.this, FoodDetailsActivity.class);
				intentFoodDetail.putExtra("type_url", detialUrl);
				intentFoodDetail.putExtra("type_name", vod_fenlei.get(position).getName());
		    	startActivity(intentFoodDetail);*/
				
			/*} catch (JSONException e) {
				e.printStackTrace();
			} catch (PadError e) {
				Toast.makeText(IndexActivity.this, e.getMessage(), Toast.LENGTH_LONG).show();
				finish();
			}*/
		}

	};    
}